package com.competition.jingdong;
//耗材
//耗材名称,耗材类型,长,宽,高
public class Consume implements Comparable{
    String consumeName;
    String consumeType;
    int consumeLength;
    int consumeWeight;
    int consumeHigh;
    long volume;
    Consume(String consumeName,String consumeType,int consumeLength,int consumeWeight,int consumeHigh)
    {
        this.consumeName=consumeName;
        this.consumeType=consumeType;
        this.consumeLength=consumeLength;
        this.consumeWeight=consumeWeight;
        this.consumeHigh=consumeHigh;
        this.volume = consumeLength*consumeWeight*consumeHigh;
        //System.out.println("构造箱子:"+consumeLength+","+consumeWeight+","+consumeHigh+","+this.volume);
    }
    Consume(NewConsume nc)
    {
        this.consumeName = nc.newConsumeName;
        this.consumeLength = nc.length;
        this.consumeWeight = nc.weight;
        this.consumeHigh = nc.high;
        this.consumeType = "箱";
        this.volume=nc.volume;
    }
    Consume(Consume old)
    {
        this.consumeName=old.consumeName;
        this.consumeHigh=old.consumeHigh;
        this.consumeType=old.consumeType;
        this.consumeLength=old.consumeLength;
        this.consumeWeight=old.consumeWeight;
        this.volume=old.volume;
    }

    @Override
    public String toString() {
        return "Consume{" +
                "consumeName='" + consumeName + '\'' +
                ", consumeType='" + consumeType + '\'' +
                ", consumeLength=" + consumeLength +
                ", consumeWeight=" + consumeWeight +
                ", consumeHigh=" + consumeHigh +
                ", volume=" + volume +
                '}';
    }
    //耗材排序按体积降序
    @Override
    public int compareTo(Object o) {
        if(this.volume>((Consume) o).volume)
            return -1;
        else
            return 1;
    }
}
